package com.shuqi.controller;

import android.content.Context;

import com.shuqi.interfaces.IEventListener;
import com.shuqi.model.AccountBindNextModel;
import com.shuqi.model.AcountBindValidationModel;

/**
 * 
 * @author yaozhen 手机绑定页面的controller用于获取短信验证码以及验证手机号和短信验证码
 * 
 */
public class AcountBindVerifyCodeController extends ControllerBase {

    public static final int ACCOUNT_BIND_VALIDATION = 0;

    public static final int ACCOUNT_BIND_NEXT = 1;

    public static final int REGISTER_TYPE = 1001; // 注册传入的参数

    public static final int BIND_TYPE = 1002; // 绑定传入的参数

    public static final int FINDPASSWORD_TYPE = 1003;// 找回密码传入的参数

    private AcountBindValidationModel validationModel;

    private AccountBindNextModel nextModel;

    public AcountBindVerifyCodeController(Context context) {
        this.validationModel = new AcountBindValidationModel(context);
        this.nextModel = new AccountBindNextModel(context);
    }

    @Override
    public void addEventListener(IEventListener listener) {
        validationModel.addEventListener(listener);
        nextModel.addEventListener(listener);
    }


    @Override
    public void handle(int eventType, Object... obj) {
        switch (eventType) {
            case ACCOUNT_BIND_VALIDATION:
                validationModel.loadData(obj);
                break;
            case ACCOUNT_BIND_NEXT:
                nextModel.loadData(obj);
                break;
            default:
                break;
        }
    }

    @Override
    public void onDestroy() {
        if (validationModel != null) {
            validationModel.onDestroy();
        }
        if (nextModel != null) {
            nextModel.onDestroy();
        }
    }
}
